package masterjava.common.client.gwt.settings;

import com.google.gwt.user.client.rpc.AsyncCallback;
import masterjava.common.client.gwt.rpc.CustomRpc;
import masterjava.common.shared.settings.SettingsRequest;
import masterjava.common.shared.settings.SettingsResponse;

import java.util.HashMap;

/**
 * User: gkislin
 * Date: 7/26/11
 */
public class AppSettings {
    private static HashMap<String, Object> settings;

    public static void send(AsyncCallback<SettingsResponse> callback) {
        CustomRpc.send(new SettingsRequest(), callback);
    }

    public static void setSettings(HashMap<String, Object> settings) {
        AppSettings.settings = settings;
    }

    public static HashMap<String, Object> getSettings() {
        return settings;
    }

    @SuppressWarnings("unchecked")
    public static <T> T get(Enum key) {
        return (T) settings.get(key.name());
    }
}
